home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-27 | 49.3 KB | 1,841 lines |
- ;OCL{{{}}}
- ;OCL{{{ shell-mode
- @if-using ( SHELL-MODE )
- ;OCL{{{ variables
- ( defvar
- ( I-op
- I-menu-xwin
- I-xwin
- I-ywin
- I-entered-filed
- I-hash
- I-arg-file-set
- I-selected
- I-help
- I-edit-extern
- )
- )
- ( history I-arg-file )
- ( history I-file-source )
- ( history I-menu-directory )
- ;OCL}}}
- ;OCL{{{ switch to editor
- ;OCL{{{ variables
- ( defvar
- ( shell-mode-re
- shell-mode-delay
- shell-mode-pos
- shell-mode-over
- )
- )
- ;OCL}}}
- ;OCL{{{ begin-modeori
- ( deffun begin-modeori
- ( set shell-mode-active false
- screen-off
- ;OCL{{{ overwrite
- if shell-mode-over ( add-mode-overwrite ) fi
- ;OCL}}}
- ;OCL{{{ statusline
- if not(status-line) ( status-line-off ) fi
- ;OCL}}}
- ;OCL{{{ regular expression
- case
- ( =(2 shell-mode-re) ( add-mode-extended-regular-expression ) )
- ( =(1 shell-mode-re) ( add-mode-basic-regular-expression ) )
- esac
- ;OCL}}}
- ;OCL{{{ autosave
- if shell-mode-delay
- ( set modify-behaviour shell-mode-delay
- add-mode-autosave
- set modify-behaviour 0
- )
- fi
- ;OCL}}}
- ;OCL{{{ position
- if shell-mode-pos ( add-mode-position ) fi
- ;OCL}}}
- ;OCL{{{ autolanguage
- if auto-language
- ( set-user-mode AL )
- fi
- ;OCL}}}
- ;OCL{{{ edit
- set-user-mode ED
- ;OCL}}}
- ;OCL{{{ raw
- if =(extended-version 0)
- ( set-user-mode NOEX )
- fi
- ;OCL}}}
- ;OCL{{{ extended
- @if-using ( L-EXT )
- if >(extended-version 0)
- ( set-user-mode LEXT )
- fi
- @fi
- ;OCL}}}
- ;OCL{{{ screen-based
- if stepping
- ( set-user-mode STEP )
- fi
- ;OCL}}}
- ;OCL{{{ auto-indent
- if auto-indent
- ( set-user-mode AI )
- fi
- ;OCL}}}
- ;OCL{{{ buffer-save
- if buff-saving ( reset-user-mode BS ) fi
- ;OCL}}}
- ;OCL{{{ EDT
- @if-using ( SUNEDT )
- if EDT-used
- ( set-user-mode EDT-TAG
- ;OCL{{{ backup
- if EDT-move-back
- ( reset-user-mode EDT-backup )
- fi
- ;OCL}}}
- )
- fi
- @fi
- ;OCL}}}
- screen-on
- redraw-display
- edit
- read-newfile-macro
- )
- )
- ;OCL}}}
- ;OCL{{{ end-modeori
- ( deffun end-modeori
- ( set shell-mode-active true
- screen-off
- ;OCL{{{ overwrite
- set shell-mode-over false
- if test-overwrite
- ( set shell-mode-over true
- delete-mode-overwrite
- )
- fi
- ;OCL}}}
- ;OCL{{{ statusline
- status-line-on
- ;OCL}}}
- ;OCL{{{ regular expression
- delete-mode-regular-expression
- set shell-mode-re ocl-argument
- ;OCL}}}
- ;OCL{{{ autosave
- delete-mode-autosave
- set shell-mode-delay ocl-argument
- ;OCL}}}
- ;OCL{{{ position
- set shell-mode-pos show-position
- delete-mode-position
- ;OCL}}}
- ;OCL{{{ autolanguage
- reset-user-mode AL
- ;OCL}}}
- ;OCL{{{ edit
- reset-user-mode ED
- ;OCL}}}
- ;OCL{{{ extended/raw
- reset-user-mode NOEX
- @if-using ( L-EXT )
- reset-user-mode LEXT
- @fi
- ;OCL}}}
- ;OCL{{{ screen-based
- reset-user-mode STEP
- ;OCL}}}
- ;OCL{{{ auto-indent
- reset-user-mode AI
- ;OCL}}}
- ;OCL{{{ buffer-save
- reset-user-mode BS
- ;OCL}}}
- ;OCL{{{ EDT
- @if-using ( SUNEDT )
- reset-user-mode EDT-TAG
- reset-user-mode EDT-backup
- @fi
- ;OCL}}}
- screen-on
- redraw-display
- )
- )
- ;OCL}}}
- ;OCL{{{ undeclares
- ( undeclare
- ( shell-mode-re
- shell-mode-delay
- shell-mode-pos
- shell-mode-over
- )
- )
- ;OCL}}}
- ;OCL}}}
- ;OCL{{{ macros
- ;OCL{{{ I-go-mouse
- ( deffun I-go-mouse
- ( if not(mouse-outside)
- ( while >(mouse-go-y 0)
- ( next-line
- set mouse-go-y -(mouse-go-y 1)
- )
- while <>(mouse-go-y 0)
- ( previous-line
- set mouse-go-y +(mouse-go-y 1)
- )
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ add-mode-shell
- ( demand-load (
- ( deffun add-mode-shell
- ( if not(ocl-arg-field(15))
- ( set ocl-arg-field(15) -1
- screen-off
- history-edit I-menu-directory ()
- default-menu-file
- newline-and-indent
- screen-on
- set I-op 1
- set-user-mode I-XS-EDIT
- message ( "[ModeOriShell " "active] )
- )
- fi
- )
- )
- ) )
- ;OCL}}}
- ;OCL{{{ menu sub functions
- ;OCL{{{ I-clear-user-modes
- ( deffun I-clear-user-modes
- ( reset-user-mode I-XS-MAIN
- reset-user-mode I-XS-FILE
- reset-user-mode I-XS-EDIT
- reset-user-mode I-XS-BROWSE
- )
- )
- ;OCL}}}
- ;OCL{{{ I-history-edit-filename
- ( deffun I-history-edit-filename
- ( screen-off
- history-edit-line I-arg-file ()
- ;OCL{{{ move to start of filename, maybe strip long info
- end-of-line
- do
- ( backward-character )
- while not(or(test-char-set space test-begin-line))
- if test-char-set space
- ( forward-character )
- fi
- while not(test-begin-line)
- ( raw-delete-previous-character )
- ;OCL}}}
- if not(test-char path-separator)
- ;OCL{{{ get leading path
- ( get-history I-menu-directory 0
- if test-begin-line
- ( default-menu-file )
- fi
- insert-ascii path-separator
- )
- ;OCL}}}
- fi
- beginning-of-line
- ;OCL{{{ maybe replace leading ~/ by $HOME/
- if
- and
- ( test-char "~
- pre ( forward-character ) test-char path-separator
- )
- ( delete-previous-character
- "$HOME
- )
- fi
- ;OCL}}}
- ;OCL{{{ maybe cut dir/.. sequences
- end-of-line
- while not(test-begin-line)
- ( if
- ;OCL{{{ /.. found
- and
- ( pre
- ( backward-character )
- and(not(test-begin-line) test-char ".)
- pre
- ( backward-character )
- and(not(test-begin-line) test-char ".)
- pre
- ( backward-character )
- and(not(test-begin-line) test-char path-separator)
- )
- ;OCL}}}
- ;OCL{{{ check and do the dir/.. remove
- (
- ;OCL{{{ skip /
- do
- ( backward-character )
- while and(not(test-begin-line) test-char path-separator)
- ;OCL}}}
- ;OCL{{{ skip dir name
- do
- ( backward-character )
- while
- and
- ( not(test-begin-line)
- not(test-char path-separator)
- not(test-char ". )
- )
- ;OCL}}}
- if test-char path-separator
- ;OCL{{{ remove dir/.. from name!
- ( do
- ( delete-character )
- while not(test-char path-separator)
- do
- ( delete-character )
- while test-char path-separator
- delete-character
- delete-character
- end-of-line
- if test-begin-line
- ( insert-ascii path-separator )
- fi
- )
- ;OCL}}}
- fi
- )
- ;OCL}}}
- fi
- )
- ;OCL}}}
- newline-and-indent
- set I-arg-file-set true
- screen-on
- )
- )
- ;OCL}}}
- ;OCL{{{ I-check-arg
- ( deffun I-check-arg
- ( set I-arg-file-set false
- if I-selected
- ;OCL{{{ get selected file
- ( beginning-of-fold
- while not(test-bottom)
- ( if
- ;OCL{{{ selected file
- and
- ( test-filed
- pre ( goto 6 ) test-str ( " "* " )
- )
- ;OCL}}}
- ;OCL{{{ get file from dir/line
- ( I-history-edit-filename
- end-of-fold
- )
- ;OCL}}}
- else
- ;OCL{{{ try next line
- ( open-fold
- next-line
- )
- ;OCL}}}
- fi
- )
- beginning-of-line
- )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ( demand-load (
- ;OCL{{{ I-prompt-for-file
- ( deffun ( p ) I-prompt-for-file
- ( case
- ( =(p 0) ( history-edit I-arg-file "Directory ) )
- ( pre(set p -(p 1))=(p 0) ( history-edit I-arg-file "Source-File ) )
- ( pre(set p -(p 1))=(p 0) ( history-edit I-arg-file "Destination-File ) )
- default
- ( history-edit I-arg-file "File )
- esac
- do
- ( begin-prompt-macro
- prompt-char-counter I-help ()
- end-prompt-macro
- if =(I-help newline-and-indent)
- ;OCL{{{ add current path and maybe use default
- ( end-of-line
- if test-begin-line
- ( if <(p 0)
- ( default-edit-file )
- else
- ( default-menu-file )
- fi
- )
- else
- ( beginning-of-line
- if and(not(test-char path-separator) not(test-char "~))
- ( get-history I-menu-directory 0
- if test-begin-line
- ( default-menu-file )
- fi
- insert-ascii path-separator
- )
- fi
- )
- fi
- end-of-line
- )
- ;OCL}}}
- fi
- insert-ascii I-help
- )
- while <>(I-help newline-and-indent)
- set I-arg-file-set true
- )
- )
- ;OCL}}}
- ) )
- ;OCL{{{ I-center-xoff
- ( deffun I-center-xoff
- ( set I-xwin +(div(-(screen-width I-xwin) 2) 1)
- if <=(I-xwin 0) ( set I-xwin 1 ) fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-default-win
- ( deffun I-default-win
- ( I-clear-user-modes
- if >(ocl-arg-field(15) 0)
- ( if >(screen-height 10)
- ;OCL{{{ use window and return
- ( screen-off
- set-area 5
- ;OCL{{{ write centered mode name
- set I-ywin 2
- set I-xwin 22
- I-center-xoff
- set I-menu-xwin +(I-xwin 13)
- write-area I-xwin I-ywin ( "ModeOriShell- )
- ;OCL}}}
- ;OCL{{{ write ( ? for list of keys ) at left border
- set I-xwin 8
- set I-ywin 5
- write-area I-xwin I-ywin ( "( " "? " "for " "list " "of " "keys " ") )
- ;OCL}}}
- ;OCL{{{ write ( i for info ) at right border
- @if-using not( NO-HELP-BROWSER )
- set I-xwin -(screen-width 20)
- if <=(I-xwin 32)
- ( set I-xwin 32 )
- fi
- write-area I-xwin I-ywin ( "( " "i " "for " "info " ") )
- @fi
- ;OCL}}}
- ;OCL{{{ write space at end of line to force inverse line!
- set I-xwin +(I-xwin screen-width)
- write-area I-xwin I-ywin ( " )
- ;OCL}}}
- screen-on
- redraw-display
- return-from-macro
- )
- ;OCL}}}
- fi
- set ocl-arg-field(15) -1
- )
- fi
- ;OCL{{{ use modes
- set-area 0
- ;OCL}}}
- )
- )
- ;OCL}}}
- ;OCL}}}
- ;OCL{{{ main-menu
- ;OCL{{{ I-main-area
- ( deffun I-main-area
- ( I-default-win
- if >(ocl-arg-field(15) 0)
- ;OCL{{{ write in window
- ( set I-ywin 2
- write-area I-menu-xwin I-ywin ( "Main-Menu )
- set I-ywin 3
- set I-xwin 65
- I-center-xoff
- write-area I-xwin I-ywin
- ( "Directory
- " " "Browser
- " " "File
- " " "Edit
- " " "Select
- " " "Make
- " " "Postbox
- " " "News
- " " "Quit
- )
- )
- ;OCL}}}
- else
- ;OCL{{{ use modes
- ( set-user-mode I-XS-MAIN )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-quit-shell
- ( deffun I-quit-shell
- ( while true
- ( set-file-unchanged
- exit-buffer
- )
- )
- )
- ;OCL}}}
- ;OCL{{{ I-start-main
- ( defmac I-start-main
- (
- ;OCL{{{ get current menu file
- read-file
- get-history I-menu-directory 0
- if test-begin-line
- ( default-menu-file )
- fi
- newline-and-indent
- history-edit-filename I-menu-directory ()
- newline-and-indent
- goto 1
- ;OCL}}}
- ;OCL{{{ set modes
- set I-selected 0
- delete-mode-view
- delete-mode-hash-shift
- set-file-unchanged
- I-Main-Menu
- ;OCL}}}
- I-main-area
- )
- )
- ;OCL}}}
- ;OCL{{{ I-re-enter-main
- ( deffun I-re-enter-main
- ( I-Main-Menu
- I-main-area
- set I-op 0
- )
- )
- ;OCL}}}
- ;OCL{{{ I-main-reread
- ( deffun I-main-reread
- ( set I-selected 0
- read-file
- get-history I-menu-directory 0
- if test-begin-line
- ( default-menu-file )
- fi
- newline-and-indent
- goto 1
- delete-mode-view
- delete-mode-hash-shift
- set-file-unchanged
- )
- )
- ;OCL}}}
- ;OCL{{{ I-change-commands
- ( deffun I-change-commands
- ( command-para-menu
- I-Main-Menu
- )
- )
- ;OCL}}}
- ( demand-load (
- ;OCL{{{ I-msg-extern-edit
- ( deffun I-msg-extern-edit
- ( message ( "[ "starting " history I-edit-cmd "] ) )
- )
- ;OCL}}}
- ;OCL{{{ I-refresh-directory
- ( deffun I-refresh-directory
- ( screen-off
- I-re-enter-main
- I-main-reread
- screen-on
- center-and-redraw-display
- )
- )
- ;OCL}}}
- ;OCL{{{ I-change-directory
- ( deffun I-change-directory
- ( screen-off
- I-check-arg
- if not(I-arg-file-set)
- ( screen-on
- redraw-display
- I-prompt-for-file(0)
- screen-off
- )
- fi
- ;OCL{{{ get directory
- read-file
- get-history I-arg-file 0
- newline-and-indent
- ;OCL}}}
- set I-selected 0
- ;OCL{{{ check dir and restore screen
- if >(file-type 0)
- ;OCL{{{ store name
- ( history-edit-filename I-menu-directory ()
- newline-and-indent
- screen-on
- redraw-display
- )
- ;OCL}}}
- else
- ;OCL{{{ restore old and complain
- ( I-main-reread
- screen-on
- redraw-display
- message ( "[ "No " "such " "directory "] )
- )
- ;OCL}}}
- fi
- ;OCL}}}
- delete-mode-view
- delete-mode-hash-shift
- set-file-unchanged
- )
- )
- ;OCL}}}
- ;OCL{{{ I-edit
- ( deffun I-edit
- (
- ;OCL{{{ get edit file (from selection or prompt)
- screen-off
- I-check-arg
- screen-on
- if not(I-arg-file-set)
- ( redraw-display
- I-prompt-for-file(-1)
- )
- fi
- ;OCL}}}
- if I-edit-extern
- ;OCL{{{ call external editor
- ( I-msg-extern-edit
- screen-off
- local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- cd-cmd " ;
- get-history I-menu-directory 0
- cmd-separator
- get-history I-edit-cmd 0
- " ;
- get-history I-arg-file 0
- newline-and-indent
- )
- newline-and-indent
- screen-on
- I-main-reread
- )
- ;OCL}}}
- else
- ;OCL{{{ switch to edit
- ( set I-op 1
- read-file
- get-history I-arg-file 0
- newline-and-indent
- redraw-display
- end-shell-mode
- message ( history error-list )
- )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-call-cmd
- ( deffun ( cmd ) I-call-cmd
- ( local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- get-history I-menu-directory 0
- if test-begin-line
- ( default-menu-file )
- fi
- cmd-separator
- insert-ascii cmd
- beginning-of-line
- cd-cmd " ;
- newline-and-indent
- )
- newline-and-indent
- if ocl-argument
- ( failed )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-make
- ;OCL{{{ I-get-make-cmd
- ( deffun I-get-make-cmd ( get-history make-cmd-hist 0 ) )
- ;OCL}}}
-
- ( deffun I-make ( I-call-cmd(I-get-make-cmd) ) )
- ;OCL}}}
- ;OCL{{{ I-mail
- ;OCL{{{ I-get-mail-cmd
- ( deffun I-get-mail-cmd ( get-history mail-cmd-hist 0 ) )
- ;OCL}}}
-
- ( deffun I-mail ( I-call-cmd(I-get-mail-cmd) ) )
- ;OCL}}}
- ;OCL{{{ I-nn
- ;OCL{{{ I-get-nn-cmd
- ( deffun I-get-nn-cmd ( get-history I-nn-cmd 0 ) )
- ;OCL}}}
-
- ( deffun I-nn ( I-call-cmd(I-get-nn-cmd) ) )
- ;OCL}}}
- ;OCL{{{ I-open-fold
- ( defmac I-open-fold ( open-fold ) )
- ;OCL}}}
- ;OCL{{{ I-close-fold
- ( defmac I-close-fold ( close-fold ) )
- ;OCL}}}
- ;OCL{{{ I-toggle-select
- ( deffun I-toggle-select
- ( if test-filed
- ;OCL{{{ toggle the selection
- ( forward-character
- forward-character
- forward-character
- forward-character
- forward-character
- if test-char " ;
- ( delete-character delete-character delete-character
- set I-selected -(I-selected 1)
- )
- else
- ( " "* " ;
- set I-selected +(I-selected 1)
- )
- fi
- beginning-of-line
- set-file-unchanged
- )
- ;OCL}}}
- fi
- I-open-fold
- next-line
- message ( counter I-selected " "files " "selected )
- )
- )
- ;OCL}}}
- ;OCL{{{ I-action-select
- ( deffun I-action-select
- ( if test-filed
- ( screen-off
- I-history-edit-filename
- read-file
- get-history I-arg-file 0
- newline-and-indent
- if =(file-type 0)
- ;OCL{{{ edit the file
- ( if I-edit-extern
- ;OCL{{{ call external editor
- ( I-msg-extern-edit
- screen-off
- local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- get-history I-edit-cmd 0
- " ;
- get-history I-arg-file 0
- newline-and-indent
- )
- newline-and-indent
- screen-on
- I-main-reread
- )
- ;OCL}}}
- else
- ;OCL{{{ switch to edit
- ( set I-op 1
- screen-on
- redraw-display
- end-shell-mode
- )
- ;OCL}}}
- fi
- )
- ;OCL}}}
- else
- ;OCL{{{ continue shell-mode
- ( set I-selected 0
- history-edit-filename I-menu-directory ()
- newline-and-indent
- screen-on
- redraw-display
- delete-mode-view
- delete-mode-hash-shift
- set-file-unchanged
- )
- ;OCL}}}
- fi
- )
- else
- ( I-open-fold
- next-line
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-toggle-expert-mode
- ( deffun I-toggle-expert-mode
- ( set ocl-arg-field(15) -ocl-arg-field(15)
- I-main-area
- )
- )
- ;OCL}}}
- ) )
- ;OCL}}}
- ;OCL{{{ file-menu
- ( demand-load (
- ;OCL{{{ I-file-area
- ( defmac I-file-area
- ( I-default-win
- if >(ocl-arg-field(15) 0)
- ;OCL{{{ use win
- ( set I-ywin 2
- write-area I-menu-xwin I-ywin ( "File-Menu )
- set I-xwin 24
- I-center-xoff
- set I-ywin 3
- write-area I-xwin I-ywin ( "Copy " " "Move " " "Remove " " "Quit )
- )
- ;OCL}}}
- else
- ;OCL{{{ use mode
- ( set-user-mode I-XS-FILE )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-file-menu
- ( deffun I-file-menu
- ( I-File-Menu
- I-file-area
- set I-op 2
- )
- )
- ;OCL}}}
- ;OCL{{{ I-quit-file-menu
- ( deffun I-quit-file-menu ( I-re-enter-main ) )
- ;OCL}}}
- ;OCL{{{ I-remove-file
- ;OCL{{{ prompt-file-remove
- ( defmac prompt-file-remove
- ( screen-off
- history-edit string-buffer ()
- "remove " "file " get-history I-arg-file 0
- newline-and-indent
- screen-on
- set I-help eval ( yes-no-menu(false) )
- )
- )
- ;OCL}}}
-
- ( deffun I-remove-file
- ( if not(I-selected)
- ;OCL{{{ prompt for file and do it
- ( I-prompt-for-file(1)
- prompt-file-remove
- if I-help
- ( local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- rm-cmd
- " get-history I-arg-file 0
- newline-and-indent
- set I-help ocl-argument
- )
- )
- fi
- )
- ;OCL}}}
- else
- ;OCL{{{ remove selected files
- ( beginning-of-fold
- do
- ( if
- ;OCL{{{ selected line
- and
- ( pre
- ( search-forward "...F " " "* " newline-and-indent )
- test-filed
- pre
- ( goto 6 )
- test-str ( " "* " )
- )
- ;OCL}}}
- ;OCL{{{ remove and save exit
- ( screen-off
- I-history-edit-filename
- screen-on
- prompt-file-remove
- if I-help
- ( local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- rm-cmd
- " get-history I-arg-file 0
- newline-and-indent
- )
- newline-and-indent
- set I-help ocl-argument
- )
- fi
- next-line
- beginning-of-line
- )
- ;OCL}}}
- else
- ;OCL{{{ end
- ( set I-help -1 )
- ;OCL}}}
- fi
- )
- while not(I-help)
- )
- ;OCL}}}
- fi
- I-main-reread
- message ()
- if >(I-help 0)
- ( message ( "[failed " "for " history I-arg-file "] ) )
- fi
- )
- )
- ( undeclare ( prompt-file-remove ) )
- ;OCL}}}
- ;OCL{{{ I-copy-or-move-file
- ( deffun ( op ) I-copy-or-move-file
- ( if not(I-selected)
- ;OCL{{{ prompt for file
- ( I-prompt-for-file(1)
- screen-off
- history-edit I-file-source ()
- get-history I-arg-file 0
- newline-and-indent
- screen-on
- )
- ;OCL}}}
- fi
- I-prompt-for-file(2)
- screen-off
- set I-help 0
- if I-selected
- ;OCL{{{ copy/move selected files
- (
- ;OCL{{{ save destination
- history-edit I-file-source ()
- get-history I-arg-file 0
- newline-and-indent
- ;OCL}}}
- beginning-of-fold
- do
- ( if
- ;OCL{{{ selected line
- and
- ( test-filed
- pre ( goto 6 ) test-str ( " "* " )
- )
- ;OCL}}}
- ;OCL{{{ copy/move and save exit
- ( I-history-edit-filename
- local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- if op ( cp-cmd ) else ( mv-cmd ) fi
- " get-history I-arg-file 0
- " get-history I-file-source 0
- newline-and-indent
- )
- newline-and-indent
- set I-help ocl-argument
- )
- ;OCL}}}
- fi
- I-open-fold
- next-line
- )
- while and(not(test-bottom) not(I-help))
- )
- ;OCL}}}
- else
- ;OCL{{{ copy/move entered file
- ( local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- if op ( cp-cmd ) else ( mv-cmd ) fi
- " get-history I-file-source 0
- " get-history I-arg-file 0
- newline-and-indent
- )
- newline-and-indent
- )
- ;OCL}}}
- fi
- I-main-reread
- screen-on
- redraw-display
- message ()
- if I-help
- ( message ( "[failed " "for " history I-arg-file "] ) )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-copy-file
- ( deffun I-copy-file ( I-copy-or-move-file(true) ) )
- ;OCL}}}
- ;OCL{{{ I-move-file
- ( deffun I-move-file ( I-copy-or-move-file(false) ) )
- ;OCL}}}
- ) )
- ;OCL}}}
- ;OCL{{{ browser
- ( demand-load (
- ;OCL{{{ I-browser-area
- ( defmac I-browser-area
- ( I-default-win
- if >(ocl-arg-field(15) 0)
- ;OCL{{{ use win
- ( set I-ywin 2
- write-area I-menu-xwin I-ywin ( "Browser )
- set I-xwin 57
- I-center-xoff
- set I-ywin 3
- write-area I-xwin I-ywin ( "Move "( "Up/Down ") " " "Enter "( "Return ") " " "Exit "( "Backspace/Delete ") " " "Quit )
- )
- ;OCL}}}
- else
- ;OCL{{{ use mode
- ( set-user-mode I-XS-BROWSE )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-browser
- ( deffun I-browser
- ( message "[loading]
- screen-off
- I-check-arg
- I-Browser
- I-browser-area
- set I-op 3
- read-file
- if I-arg-file-set
- ( get-history I-arg-file 0 )
- else
- ( default-browser-file )
- fi
- newline-and-indent
- screen-on
- message "[formatting]
- screen-off
- no-overstrike
- screen-on
- redraw-display
- )
- )
- ;OCL}}}
- ;OCL{{{ I-quit-browser
- ( deffun I-quit-browser
- ( reset-user-mode I-ENT
- I-re-enter-main
- I-main-reread
- )
- )
- ;OCL}}}
- ;OCL{{{ I-info-enter
- ( deffun I-info-enter
- ( if or(test-fold-line test-filed)
- ( message "[loading]
- ;OCL{{{ clear last-message-memory
- if
- or
- ( last-message M_NO_TEXT
- last-message M_NO_ENTER_LIST_FF
- last-message M_CANTOPEN
- )
- ()
- fi
- ;OCL}}}
- screen-off
- enter-fold
- if
- ;OCL{{{ failed
- or
- ( last-message M_NO_TEXT
- last-message M_NO_ENTER_LIST_FF
- last-message M_CANTOPEN
- )
- ;OCL}}}
- ;OCL{{{ message
- ( screen-on
- redraw-display
- message ( "[ "Currently " "not " "available! "] )
- )
- ;OCL}}}
- else
- ;OCL{{{ count enter
- ( set I-entered-filed +(I-entered-filed 1)
- set-numbered-user-mode I-ENT I-entered-filed
- delete-mode-view
- delete-mode-hash-shift
- set-file-unchanged
- if =(set-enter 0)
- ( screen-on
- message "[formating]
- screen-off
- no-overstrike
- )
- fi
- screen-on
- redraw-display
- message ()
- )
- ;OCL}}}
- fi
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ I-info-exit
- ;OCL{{{ open2enter
- ( defmac open2enter
- ( local
- ( ocl-argument )
- ( if last-message M_TOP () fi
- if last-message M_USE_EXIT () fi
- set ocl-argument store-line
- close-fold
- if not(or(last-message M_TOP last-message M_USE_EXIT))
- ( open2enter
- enter-fold
- while <>(store-line ocl-argument)
- ( next-line )
- )
- fi
- )
- )
- )
- ;OCL}}}
- ( deffun I-info-exit
- ( if I-entered-filed
- ( screen-off
- set I-entered-filed -(I-entered-filed 1)
- exit-fold
- if not(I-entered-filed)
- ( reset-user-mode I-ENT )
- else
- ( set-numbered-user-mode I-ENT I-entered-filed )
- fi
- open2enter
- screen-on
- redraw-display
- )
- fi
- )
- )
- ;OCL}}}
- ) )
- ;OCL}}}
- ;OCL{{{ startup
- ;OCL{{{ I-startup-read
- ( deffun I-startup-read
- (
- ;OCL{{{ get EDIT_CMD
- set I-edit-extern true
- history-edit I-edit-cmd ()
- get-edit-cmd-var
- if
- ;OCL{{{ end of echo and default or not used
- pre
- ( beginning-of-line
- next-non-space-on-line
- )
- or
- ( test-end-line
- test-str "default
- )
- ;OCL}}}
- ;OCL{{{ clear cmd, use default
- ( beginning-of-line
- delete-to-end-of-line
- set I-edit-extern false
- )
- ;OCL}}}
- fi
- newline-and-indent
- ;OCL}}}
- ;OCL{{{ get NN_CMD
- history-edit I-nn-cmd ()
- get-nn-cmd-var
- if test-begin-line
- ( nn-cmd-def )
- fi
- newline-and-indent
- ;OCL}}}
- )
- )
- ;OCL}}}
- ;OCL{{{ I-startup
- ( deffun I-startup
- ( if I-edit-extern
- ( message ( "[ "Editor " "is " history I-edit-cmd "] ) )
- else
- ( message ( "[ "Editor " "is " "ModeOri "] ) )
- fi
- )
- )
- ;OCL}}}
- ;OCL}}}
- ;OCL{{{ I-restart-shell
- ( deffun I-restart-shell
- ( case
- ;OCL{{{ restart main-menu
- ( =(I-op 0)
- ( case
- ;OCL{{{ normal file at startup -> call editor
- ( =(file-type 0)
- ( set I-op 1
- if I-edit-extern
- ;OCL{{{ call external editor
- ( screen-off
- history-edit-filename I-arg-file ()
- newline-and-indent
- screen-on
- I-msg-extern-edit
- screen-off
- local
- ( force-bourne-shell )
- ( set force-bourne-shell true
- shell-command
- get-history I-edit-cmd 0
- " ;
- get-history I-arg-file 0
- newline-and-indent
- )
- newline-and-indent
- screen-on
- )
- ;OCL}}}
- else
- ;OCL{{{ switch to edit
- ( history-edit I-menu-directory ()
- ".
- newline-and-indent
- end-shell-mode
- return-from-macro
- )
- ;OCL}}}
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ directory file at startup -> use this in menu
- ( >(file-type 0)
- ( history-edit-filename I-menu-directory ()
- newline-and-indent
- )
- )
- ;OCL}}}
- esac
- ;OCL{{{ start menu with default or last value
- I-start-main
- ;OCL}}}
- )
- )
- ;OCL}}}
- ;OCL{{{ came from editor -> restart main-menu
- (=(I-op 1)
- ( set I-op 0
- I-start-main
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ begin-shell-mode
- ( deffun begin-shell-mode
- ( end-modeori
- set I-hash counter test-hash-shift
- I-restart-shell
- )
- )
- ;OCL}}}
- ;OCL{{{ end-shell-mode
- ( deffun end-shell-mode
- ( reset-user-mode I-ENT
- if I-hash ( add-mode-hash-shift ) else ( delete-mode-hash-shift ) fi
- set-file-unchanged
- if >(ocl-arg-field(15) 0)
- ;OCL{{{ use area for QE-user-help
- ( set-area 5
- ;OCL{{{ write centered mode name
- set I-xwin 22
- I-center-xoff
- set I-ywin 2
- write-area I-xwin I-ywin ( "ModeOriShell-Editor )
- ;OCL}}}
- ;OCL{{{ write help for save/quit/open/close
- set I-xwin 72
- I-center-xoff
- set I-ywin 3
- write-area I-xwin I-ywin
- ( "Save: " "esc " "s " "a
- " " " "Quit: " "esc " "q " "u
- " " " "Open " "fold: " "esc " "o " "p
- " " " "Close " "fold: " "esc " "c " "l
- )
- ;OCL}}}
- ;OCL{{{ write ( esc h b for list of keys ) at left border
- set I-xwin 6
- set I-ywin 5
- write-area I-xwin I-ywin ( "( " "esc " "h " "b " " "for " "list " "of " "keys " ") )
- ;OCL}}}
- ;OCL{{{ write ( esc i f for info ) at right border
- @if-using not( NO-HELP-BROWSER )
- set I-xwin -(screen-width 25)
- if <=(I-xwin 36)
- ( set I-xwin 36 )
- fi
- write-area I-xwin I-ywin ( "( " "esc " "i " "f " " "for " "info " ") )
- @fi
- ;OCL}}}
- ;OCL{{{ write space at end of line to force inverse line!
- set I-xwin +(I-xwin screen-width)
- write-area I-xwin I-ywin ( " )
- ;OCL}}}
- )
- ;OCL}}}
- else
- ;OCL{{{ no use of modes
- ( set-area 0
- I-clear-user-modes
- set-user-mode I-XS-EDIT
- )
- ;OCL}}}
- fi
- begin-modeori
- )
- )
- ;OCL}}}
- ;OCL{{{ shell-mouse
- @if-using (MOUSY)
- ( deffun ( cmd ) shell-mouse
- ( case
- ;OCL{{{ outside -> nop
- ( mouse-outside ( ) )
- ;OCL}}}
- ;OCL{{{ browser mouse handling
- ( =(I-op 3)
- ( I-go-mouse
- case
- ( =(cmd 1) ( I-info-enter ) )
- ( =(cmd -1) ( I-info-exit ) )
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ main-menu/file-menu -> go and open/nop/close
- ( or(=(I-op 0) =(I-op 2))
- ( set ocl-argument mouse-go-y
- I-go-mouse
- case
- ;OCL{{{ open or call
- ( =(cmd 1)
- ( case
- ;OCL{{{ not moved and main menu -> action select
- ( and(=(ocl-argument 0) =(I-op 0))
- ( I-action-select
- return-from-macro
- )
- )
- ;OCL}}}
- default
- ;OCL{{{ fold -> open
- ( open-fold )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ close fold
- ( =(cmd -1) ( I-close-fold ) )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- default
- ;OCL{{{ go to position
- ( I-go-mouse )
- ;OCL}}}
- esac
- message ()
- )
- )
- @fi
- ;OCL}}}
- ;OCL{{{ hooks
- ;OCL{{{ I-prompt-in
- ( deffun I-prompt-in ( para ) )
- ;OCL}}}
- ;OCL{{{ I-prompt-out
- ( deffun I-prompt-out
- ( case
- ( =(I-op 2) ( I-File-Menu ) )
- ( =(I-op 3) ( I-Browser ) )
- default
- ( I-Main-Menu )
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ I-dummy-macro
- ( deffun I-dummy-macro ())
- ;OCL}}}
- ;OCL{{{ I-crash
- ( defmac I-crash ( set-file-unchanged I-prompt-out ))
- ;OCL}}}
- ;OCL{{{ I-key-not-bound
- ( deffun I-key-not-bound ( I-crash ) )
- ;OCL}}}
- ;OCL{{{ I-abort-hook
- ( deffun I-abort-hook
- ( case
- esac
- set I-op 1
- set-file-unchanged
- I-restart-shell
- )
- )
- ;OCL}}}
- ;OCL{{{ I-view-macro
- ( deffun I-view-macro ( I-crash ) )
- ;OCL}}}
- ;OCL}}}
- ;OCL}}}
- ;OCL{{{ undeclares
- ( undeclare
- ( I-history-edit-filename
- I-clear-user-modes
- I-check-arg
- I-prompt-for-file
- I-main-area
- I-start-main
- I-re-enter-main
- I-main-reread
- I-file-area
- I-copy-or-move-file
- I-browser-area
- I-restart-shell
- I-dummy-macro
- I-crash
- default-browser-file
- default-menu-file
- default-edit-file
- cp-cmd
- mv-cmd
- rm-cmd
- I-op
- I-menu-xwin
- I-xwin
- I-ywin
- I-entered-filed
- I-hash
- I-arg-file-set
- I-selected
- I-help
- )
- )
- ;OCL}}}
- ;OCL{{{ redefine exits for shell
- ;OCL{{{ exit-buffer
- ( defmac exit-buffer- ( exit-buffer ) )
- ( undeclare ( exit-buffer ) )
- ( deffun exit-buffer
- ( if and(ocl-arg-field(15) =(used-buffers 1) not(in-prompt))
- ( if test-file-changed
- ( para
- prompt-counter ocl-argument ( M_CHANGED_LEAVE " "? " )
- edit
- if not(ocl-argument)
- ( return-from-macro )
- fi
- set-file-unchanged
- )
- fi
- begin-shell-mode
- return-from-macro
- )
- fi
- exit-buffer-
- )
- )
- ( undeclare ( exit-buffer- ) )
- ;OCL}}}
- ;OCL{{{ exit-origami
- ( deffun shell-exit-origami
- ( case
- ;OCL{{{ shell used: leave additional unchanged buffer and return to shell
- ( and(ocl-arg-field(15) not(in-prompt))
- ( while <>(used-buffers 1)
- ( if test-file-changed
- ( message ( "[ "file " "changed "] )
- return-from-macro
- )
- fi
- exit-buffer
- )
- if test-file-changed
- ( message ( "[ "file " "changed "] )
- return-from-macro
- )
- fi
- exit-buffer
- )
- )
- ;OCL}}}
- default
- ( exit-origami )
- esac
- )
- )
- ( undeclare ( exit-origami ) )
- ( defmac exit-origami ( shell-exit-origami ) )
- ;OCL}}}
- ;OCL{{{ save-and-exit-buffer
- ( defmac save-and-exit-buffer- ( save-and-exit-buffer ) )
- ( undeclare ( save-and-exit-buffer ) )
- ( deffun save-and-exit-buffer
- ( if and(ocl-arg-field(15) =(used-buffers 1) not(in-prompt))
- ( save-file
- if test-file-changed
- ( message ( "[File " "changed "!] )
- return-from-macro
- )
- else
- ( begin-shell-mode
- return-from-macro
- )
- fi
- )
- fi
- save-and-exit-buffer-
- )
- )
- ( undeclare ( save-and-exit-buffer- ) )
- ;OCL}}}
- ;OCL}}}
- @fi
- ;OCL}}}
- ;OCL{{{ edt simulation
- @if-using ( SUNEDT )
- ( demand-load (
- ;OCL{{{ EDT-find-direction
- ( deffun EDT-find-direction
- ( if EDT-move-back ( search-reverse ) else ( search-forward ) fi )
- )
- ;OCL}}}
- ;OCL{{{ EDT-find-next-direction
- ( deffun EDT-find-next-direction
- ( EDT-find-direction
- previous-line
- newline-and-indent
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-page-begin
- ( deffun EDT-page-begin
- ( while >(cursor-level 2)
- ( previous-line )
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-section-move
- ( deffun EDT-section-move
- ( repeat 16 ( if EDT-move-back ( previous-line ) else ( next-line ) fi ) )
- )
- ;OCL}}}
- ;OCL{{{ EDT-set-direction-forward
- ( deffun EDT-set-direction-forward
- ( set EDT-move-back false
- reset-user-mode EDT-backup
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-set-direction-backward
- ( deffun EDT-set-direction-backward
- ( set EDT-move-back true
- set-user-mode EDT-backup
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-word-move
- ( deffun EDT-word-move
- ( if EDT-move-back ( backward-word ) else ( forward-word ) fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-char-move
- ( deffun EDT-char-move
- ( if EDT-move-back ( backward-character ) else ( forward-character ) fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-clear-kill
- ;OCL{{{ EDT-clear-kill-rec
- ( deffun EDT-clear-kill-rec
- ( case
- ;OCL{{{ handle mode view first
- ( test-view
- ( delete-mode-view
- EDT-clear-kill-rec
- add-mode-view
- )
- )
- ;OCL}}}
- ;OCL{{{ handle start of filed fold
- ( test-top
- ( next-line
- EDT-clear-kill-rec
- previous-line
- )
- )
- ;OCL}}}
- default
- ;OCL{{{ clear the buffer
- ( insert-folded-kill-buffer
- delete-line
- pop-delete-buffer
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
-
- ( deffun EDT-clear-kill
- ( if kill-count
- ( screen-off
- if test-file-changed
- ( EDT-clear-kill-rec )
- else
- ( EDT-clear-kill-rec
- set-file-unchanged
- )
- fi
- screen-on
- redraw-display
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-undelete-line
- ( deffun EDT-undelete-line
- ( if not(test-view)
- ( if last-message M_NO_UNDEL () fi
- if last-message M_ERR_PO () fi
- undo-delete-line
- if not(or(last-message M_NO_UNDEL last-message M_ERR_PO ))
- ( double-line
- delete-line
- )
- fi
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-quit-buffer
- ( deffun EDT-quit-buffer
- ( set-file-unchanged
- exit-buffer
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-exit-buffer
- ( defmac EDT-exit-buffer
- ( save-and-exit-buffer
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-toggle-mode-overwrite
- ( deffun EDT-toggle-mode-overwrite
- ( if test-overwrite
- ( delete-mode-overwrite )
- else
- ( add-mode-overwrite )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-paste-and-rekill-line
- ( deffun EDT-paste-and-rekill-line
- ( if not(test-view)
- ( if last-message M_ERR_PO () fi
- if last-message M_NO_PICK () fi
- insert-folded-kill-buffer
- if not(or(last-message M_ERR_PO last-message M_NO_PICK) )
- ( enter-fold
- while not(test-bottom)
- ( copy-to-kill-buffer
- next-line
- )
- exit-fold
- )
- fi
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-replace-line-by-kill
- ( deffun EDT-replace-line-by-kill
- ( if not(test-view)
- ( if last-message M_NO_UNDEL () fi
- if last-message M_ERR_PO () fi
- undo-delete-line
- if not(last-message M_ERR_PO)
- ( if last-message M_NO_UNDEL
- ( delete-line
- EDT-paste-and-rekill-line
- )
- else
- ( next-line
- delete-line
- previous-line
- delete-line
- EDT-paste-and-rekill-line
- )
- fi
- )
- fi
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-clear-kill-and-cut-line
- ( deffun EDT-clear-kill-and-cut-line
- ( EDT-clear-kill
- copy-to-kill-buffer
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-toggle-case-char
- ( deffun EDT-toggle-case-char
- ( case-character-toggle
- forward-character
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-insert-number-char
- ( deffun EDT-insert-number-char
- ( para
- prompt-counter ocl-argument "Coding:
- insert-ascii ocl-argument
- edit
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-delete-to-beginning-of-line
- ( deffun EDT-delete-to-beginning-of-line
- ( if not(test-view)
- ( if last-message M_ERR_PO () fi
- local
- ()
- ( while >(store-pos 1)
- ( backward-character
- if not(test-end-line)
- ( raw-delete-character
- if last-message M_ERR_PO
- ( forward-character
- return-from-macro
- )
- fi
- )
- fi
- )
- )
- )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-undo-delete-line-unfolded-at-position
- ( deffun EDT-undo-delete-line-unfolded-at-position
- ( in-at-position(EDT-undelete-line) )
- )
- ;OCL}}}
- ;OCL{{{ EDT-clear-kill-and-cut-region
- ( deffun EDT-clear-kill-and-cut-region
- ( EDT-clear-kill
- copy-kill-mark-region
- )
- )
- ;OCL}}}
- ;OCL{{{ EDT-paste-and-rekill-region
- ;OCL{{{ EDT-paste-and-rekill-line
- ( deffun EDT-paste-and-rekill-line-move
- ( EDT-paste-and-rekill-line
- previous-line
- )
- )
- ;OCL}}}
-
- ( deffun EDT-paste-and-rekill-region
- ( in-at-position(EDT-paste-and-rekill-line-move) )
- )
- ;OCL}}}
- ;OCL{{{ EDT-replace-region-by-kill
- ( deffun EDT-replace-region-by-kill
- ( delete-mark-region
- switch-to-move-mode
- EDT-paste-and-rekill-region
- )
- )
- ;OCL}}}
- ) )
- @fi
- ;OCL}}}
-